//
//  HRSquareAudioPlayerViewModel.m
//  Hear
//
//  Created by mac on 2018/4/1.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "HRSquareAudioPlayerViewModel.h"
#import "HRSquareAudioPlayerModel.h"

@implementation HRSquareAudioPlayerViewModel
-(void)getSqureAudioPlayerData:(NSDictionary*)requstDict andUrl:(NSString *)url resultArray:(void(^)(NSMutableArray *resultArray))resultArray
{
    YTKApi *api = [YTKApi apiGetWithUrl:url para:requstDict];//
    //    api.cacheTime = 1;
    [api getSuccessToken:^() {  
        api.foceNoTocken = NO;
        [api setRequestSerializerType:YTKRequestSerializerTypeJSON];
        [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
            [[NSUserDefaults standardUserDefaults] setInteger:300 forKey:@"cacheTime"];
            
            NSDictionary *dict = request.responseJSONObject;
            NSArray *resultArr = [NSArray modelArrayWithClass:[HRSquareAudioPlayerModel class] json:dict[@"BodyContent"]];

            NSMutableArray *layouts = [NSMutableArray array];
            for (HRSquareAudioPlayerModel *model in resultArr) {

                [layouts addObject:model];

            }
            resultArray(layouts);
             
        } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
            resultArray(@[]);
        }];
    }];
}
@end
